﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using webapp4U;
using webapp4U.BOL;


public partial class UserControl_ControlInNghiepVuNhapChiPhi : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ViewState["db"] != null)
        {
            ControlReportViewer1.ReportViewer.Report = CreateReport();
        }
    }
    protected void imgBtnAdd_Click(object sender, ImageClickEventArgs e)
    {
        ControlReportViewer1.ReportViewer.Report = CreateReport();
    }

    DevExpress.XtraReports.UI.XtraReport CreateReport()
    {
        dt = new ClassExecute.ClassExecute();
        XtraReportInNghiepVuNhapChiPhi tableReport = new XtraReportInNghiepVuNhapChiPhi();
        try
        {
           
            if (Session["Sitecode"] != null)
            {

               
                DataSet ds = new DataSet();

                ds = dt.Get_Data_DataSet(str, ref error, "ls_getDailyExpense", CommandType.StoredProcedure,
                    new SqlParameter("@siteCode", Session["Sitecode"].ToString()),
                    new SqlParameter("@DdMmYyyy",txtFromDate.Text));
                ViewState["db"] = ds;
                tableReport.SetReportParameter(ds);
                TabContainer1.ActiveTabIndex = 1;
            }
        }
        catch (Exception ex)
        {

            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }   
        return tableReport;
    }
}
